import {
    elementTypes
} from './element-types'

/**
 * 创建一个节点类型加数字的名称。
 */
class RandName {
    constructor(graph) {
        this.graph = graph
        this.clear()
    }

    clear() {
        this.names = {}
        for (let i in elementTypes) {
            this.names[i] = 0
        }
    }

    /**
     * 初始化已用的颜色
     * @param {Array} usedColors 已有的颜色
     */
    initialize(elements) {
        for (let i in elements) {
            this.names[elements[i].type]++
        }
    }

    nextName(type) {
        this.names[type]++
        return elementTypes[type] + this.names[type]
    }
}

export default RandName